//
//  TravelDecatilFrame.m
//  庐山通
//
//  Created by zcj on 15-10-30.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//
#define margen 10

#import "TravelDecatilFrame.h"
#import "TravelDecatil.h"
#import <UIKit/UIKit.h>
#import "Grouble.h"

@implementation TravelDecatilFrame

- (void)setTravelDecatl:(TravelDecatil *)travelDecatl
{
    _travelDecatl = travelDecatl;
    // 图片
    CGFloat avatarX = margen;
    CGFloat avatarY = margen;
    CGFloat avatarW = 35;
    CGFloat avatarH = 35;
    _avatarF = CGRectMake(avatarX, avatarY, avatarW, avatarH);
    // 用户名
    CGFloat usernameX = CGRectGetMaxX(_avatarF) + margen;
    CGFloat usernameY = avatarY + 5;
    //ZCJLog(@"-----%@----",travelDecatl.username);
    CGSize usernameWH = [travelDecatl.username sizeWithFont:[UIFont systemFontOfSize:15]];
    
    
    _usernameF = (CGRect){{usernameX,usernameY},usernameWH};
    
    // 标题
    CGFloat grouptitleX = usernameX;
    CGFloat grouptitleY = CGRectGetMaxY(_usernameF) + 5;
    
    CGSize grouptitleWH = [travelDecatl.grouptitle sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}];
    
    _grouptitleF = (CGRect){{grouptitleX,grouptitleY},grouptitleWH};
    
    // 普通用户
    CGFloat statusX = CGRectGetMaxX(_grouptitleF) + 5;
    CGFloat statusY = grouptitleY;
    CGSize statusWH = [travelDecatl.status sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}];
    _statusF = (CGRect){{statusX,statusY},statusWH};
    
    // 内容
    CGFloat contentX = avatarX;
    CGFloat contentY = CGRectGetMaxY(_statusF) + 2 * margen;
    CGFloat contentW = ScreenWidth - 2 *margen;
    
    CGSize contentWH = [travelDecatl.content boundingRectWithSize:CGSizeMake(contentW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:25]} context:nil].size;
    _contentF = (CGRect){{contentX,contentY},contentWH};
    
   // 赞
    CGFloat rankY = CGRectGetMaxY(_contentF) + margen;
    CGFloat rankX = margen * 2;
    CGFloat rankW = (ScreenWidth - 2 * margen) / 3;
   // CGSize rankWH = [[travelDecatl.status boundingRectWithSize:CGSizeMake(rankW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20]} context:nil].size;
    
    CGSize rankWH = [@"9485794" boundingRectWithSize:CGSizeMake(rankW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20]} context:nil].size;
    
    
    _rankF = (CGRect){{rankX,rankY},rankWH};
    // 拼论
    CGFloat seqidX = CGRectGetMaxX(_rankF);
    CGFloat seqidY = rankY;
    CGSize seqidWH = rankWH;
   
    _seqidF = (CGRect){{seqidX,seqidY},seqidWH};
    // 浏览量
   // posttimeF
    CGFloat posttimeX = CGRectGetMaxX(_seqidF);
    CGFloat posttimeY = seqidY;
    CGSize posttimeWH = seqidWH;
    _posttimeF = (CGRect){{posttimeX,posttimeY},posttimeWH};
 
    _cellH = CGRectGetMaxY(_posttimeF) + 2*margen;
    
}
@end
